<!--单行文本 输入框-->
<template>
    <el-input 
        v-model="inputvalue" 
        :placeholder="$t('m.Pleaseenter')+list['title_'+lang]"
        :disable="list.is_disable==1?true:false"
        @input="returnBackFn"
        clearable
    >
    </el-input>  
</template>
<script>
    export default {
        props: ["list","lang",'value','isnone'],
        data() {
            return{
                inputvalue:"",
            }
        },
        mounted(){
            this.rulesList()
        },
        methods:{
            returnBackFn(){
                this.$emit('input',this.inputvalue)
            },
            rulesList(value){
                //console.log(this.list,'lists5555')
                var arr=[],_this= this;
                if(this.list.is_require==1){
                    arr.push({ required: true,message: this.$t('m.Pleaseenter')+this.list['title_'+this.lang]})
                }
                if(this.list.maxlength != 0 && typeof(this.list.maxlength) == 'number'){
                    arr.push({min: 0,max:this.list.maxlength, message:this.list['title_'+this.lang]+this.$t('m.Upto')+this.list.maxlength+this.$t('m.Characters')})
                }
                if(this.list.rule){
                    var rulesIn  = this.list.rule;
                    for (let index = 0; index < rulesIn.length; index++) {
                        var item = rulesIn[index]
                        if(item.rule != ""){
                            arr.push({
                                validator(rule, value, callback) {
                                    if(!RegExp(item.rule).test(value)){
                                        return callback(new Error(item['error_tip_'+_this.lang]))
                                    }else{
                                        callback();
                                    }
                                }
                            })
                        }
                        
                    }
                }
                this.$emit('changeRules',this.list.name,arr,this.isnone)
            },
        },
        watch:{
            value:{
                handler(val,old){
                    //console.log(val,old,55555)
                    this.inputvalue = val;
                },
                immediate:true,
                deep:true,
            }
        }
    }
</script>